package com.example.myproject.druidandmybatis;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

import javax.sql.DataSource;


public class DruidDataSourceConfiguration {

    //因为druid连接，默认不在springboot控制范围，所以自带建立这个datasource;
    //mybatis-start-bootstarter 自身会间里sqlsessionFacgory,sqlsseintemplate,如果想自定一饿
    @Bean
    @ConfigurationProperties(prefix = "spring.datasource")
    @Primary
    public DataSource druidDataSource() {
        DruidDataSource druidDataSource = new DruidDataSource();
        return druidDataSource;
    }
}